﻿using FoodModel;
using J.FoodManageGet.Application.Command.SpecificationCommand;
using J.FoodManageGet.Application.Command.TableNumCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace J.FoodManageGet.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SpecificationController : ControllerBase
    {
        private readonly IMediator _mediator;

        public SpecificationController(IMediator mediator)
        {
           _mediator = mediator;
        }
        /// <summary>
        /// 菜品规格显示
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> SpecificationShow(SpecificationShowCommand command)
        {
            var list = await _mediator.Send(command);
            return Ok(new
            {
                list.totalCount,
                list.PagCount,
                list.list
            });
        }
        /// <summary>
        /// 菜品规格下拉框
        /// </summary>
        [HttpPost]
        public async Task<List<SpecificationModel>> Specification(SpecificationCommand command)
        {
            return await _mediator.Send(command);
          
        }
        /// <summary>
        /// 菜品规格字段截取
        /// </summary>
        [HttpPost]
        public async Task<List<SpecificationModel>> Specificationclassify(SpecificationclassifyCommand command)
        {
            return await _mediator.Send(command);
          
        }
        /// <summary>
        /// 菜品规格反填
        /// </summary>
        [HttpPost]
        public async Task<List<SpecificationModel>> SpecificationBack(SpecificationBackCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
